package cn.wolfcode.p2p.website.controller;

import cn.wolfcode.p2p.base.excetion.DisplayableExcetion;
import cn.wolfcode.p2p.base.service.IVerifyCodeService;
import cn.wolfcode.p2p.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class VerifyCodeXontroller {
    @Autowired
    private IVerifyCodeService verifyCodeService;
    @RequestMapping("sendVerifyCode")
    @ResponseBody
    public AjaxResult sendVerifyCode(String phoneNumber){
       AjaxResult result = null;
       try {
           verifyCodeService.sendVerifyCode(phoneNumber);

           result = new AjaxResult(true,"验证码已发送");
       } catch (DisplayableExcetion e) {
           e.printStackTrace();
           result = new AjaxResult(false, e.getMessage());
       } catch (Exception e) {
           e.printStackTrace();
           result = new AjaxResult(false,"系统出错,请联系管理员");
       }
       return result;
    }

}
